import { getStudentInfo,updateSubjset,addSubjset ,delSubjset} from '../api/home'

const getters = {}
const state = {
    grades: []
}
const mutations = {
    getStudentInfo(state,val){
        state.grades = val
    }
}
const actions = {
    async gradesadd(content,value){
        const {userid,grades} = value
        const result = await addSubjset({userid,grades})
        return result
    },
    async getStudentInfo(content,val){
       let result = await getStudentInfo(val)
       if(result)content.commit('getStudentInfo',result)
       return result
    },
    async updateGades(content,val){
        const {userid,grades} = val
        console.log(userid,grades,'cxcxcsdasiudyaiwoudhaikslodh')
        const result = await updateSubjset({userid,grades})
        console.log(result,'uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu');
        return result
    },
    async delSubject(content,val){
        const {userid,subjectName} = val
        let result = await delSubjset({userid,subjectName})
        return result
    }
}

export default {
    getters,
    state,
    actions,
    mutations
}